<?php
class Vfriend_Plugins_AdminController extends Zend_Controller_Plugin_Abstract
{
	public function routeStartup(Zend_Controller_Request_Abstract $objRequest)
	{
	}

	public function routeShutdown(Zend_Controller_Request_Abstract $objRequest)
	{
	}

	public function dispatchLoopStartup(Zend_Controller_Request_Abstract $objRequest)
	{
	}

	public function preDispatch(Zend_Controller_Request_Abstract $objRequest)
	{
		$objView		= Zend_Registry::get('objView');
		$strController 	= $objRequest->getControllerName();
		$strAction 		= $objRequest->getActionName();
		$AppUI 			= Vfriend_Session::start(1);
		Zend_Registry::set('AppUI', $AppUI);
		$objView->assign('AppUI', $AppUI);		
		if ($strController == 'statics' ||
			$strController == 'ajax' || 
			$strController == 'valid' || 
			($strController == 'index' && ($strAction == 'login' || $strAction == 'loginerr' || $strAction == 'logout')) 
		) {					
			return;
		}		
		/** Set Back URL **/
		$strBackURL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		if (!in_array(strrchr($strBackURL, '.'), array('.gif','.png','.jpg','.xml','.ico','.htc','.swf','.css')) && !isset($_GET['error'])) {
			if (strrchr($strBackURL, '.') == '.htc') exit;
			$_SESSION[SESSION_BACKURL] = $strBackURL;
		}		
	}

	public function postDispatch(Zend_Controller_Request_Abstract $objRequest)
	{
	}

	public function dispatchLoopShutdown()
	{
	}
}
?>